///////////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
#include <GUI.h>
//-----------------------------------------------------------------------------

UIManager*		g_ui	= NULL;

//-----------------------------------------------------------------------------

void	GUILoad()
{
	g_ui = MGL_NEW UIManager();

	Container* a = MGL_NEW Container();
	Container* b = MGL_NEW Container();
	a->AddChild( b );
	g_ui->GetContainer()->AddChild( a );
	a->SetPosition( 100, 100 );
	a->SetSize( 200, 200 );
	b->SetPosition( 20, 20 );
	b->SetSize( 50, 50 );
}

//-----------------------------------------------------------------------------

bool	GUIInput()
{
	if( g_ui && InputManager::GetInstance()->IsMouseButtonDown( 0 ) )
	{
		Container* c = g_ui->GetContainer()->GetContainerAt( InputManager::GetInstance()->GetMousePositionX(), InputManager::GetInstance()->GetMousePositionY() );
		if( c )
		{
			if( InputManager::GetInstance()->HasMouseMoved() )
			{
				c->Move( InputManager::GetInstance()->GetMouseOffsetX(), InputManager::GetInstance()->GetMouseOffsetY() );
			}
			return true;
		}
	}
	return false;
}

//-----------------------------------------------------------------------------

void	GUIDraw()
{
	if( g_ui )
	{
		g_ui->Draw();
	}
}

//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
